package Game.Buff;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import Game.Objects.GOPlayer;
import Game.Objects.GameObject;

/** Buff Mydriasis class
 * Description: increase see distance
 * @author Aikidos
 */
public class BuffMydriasis extends BuffBase {
	
	/** Old light range */
	private int _oldRange;
	
	public BuffMydriasis(BuffManager buffManager) throws SlickException {
		super(buffManager);
		
		setNumOfSteps(80);
		
		_icon = new Image("res/gfx/buff/mydriasis.png");
	}
	
	@Override
	public void init() {
		GameObject obj = getBuffManager().getOwner();
		
		// Player
		if (obj.isPlayer()) {
			GOPlayer player = (GOPlayer)obj;
			
			_oldRange = player.getSelfLight().getRange();
			player.getSelfLight().setRange(_oldRange + 10);
			
			player.getObjectManager().getLevel().getLightManager().calcLighting();
		}
	}

	@Override
	public void shutdown() throws SlickException {
		GameObject obj = getBuffManager().getOwner();
		
		// Player
		if (obj.isPlayer()) {
			GOPlayer player = (GOPlayer)obj;
			
			player.getSelfLight().setRange(_oldRange);
		}
	}
}
